/**
* @description: 标准化作业--会商分配详情
* @author: wqn
* @data:2023年6月15日
* @remark:
**/
<template>
	<view class="allocation">
		<nav-bar :title="title" @goBack="goBack"></nav-bar>
		<form-details :distribution-data="distributionData" :test-data="testData"></form-details>
	</view>
</template>

<script>
	import navBar from "../common/navBar.vue"
	import FormDetails from "../common/formDetails.vue";

	export default {
		name: "consultationAllocation",
		components: {
			FormDetails,
			navBar
		},
		data() {
			return {
				title: "",
				distributionData: [{
						label: '推演人员',
						value: ''
					},
					{
						label: '推演时间',
						value: ''
					},
					{
						label: '推演地点',
						value: ''
					},
				],
				testData: [{
						label: '分配人',
						value: ''
					},
					{
						label: '分配时间',
						value: ''
					},
				],
			}
		},
		onLoad(option) {
			this.work = JSON.parse(option.message)
			this.title = this.work.flowName === "会商分配" ?"会商分配详情" :"推演分配详情"
			if(this.work.flowName === "会商分配"){
				this.getSelectallocation()
			}else{
				this.getDeductiondetails()
			}
			
		},
		methods: {
			goBack() {
				uni.navigateBack()
			},
			getDeductiondetails() {
				let params = {
					workPlanId: this.work.id,
					consultationDeductionId: this.work.objId
				}
				this.$apiRequest.bzhzyApi.deductiondetails(params).then(res => {
					this.distributionData = [{
							label: '推演人员',
							value: `${res.data.peoplelistName4},${res.data.peoplelistName5}`
						},
						{
							label: '推演时间',
							value: res.data.deductionTime
						},
						{
							label: '推演地点',
							value: res.data.deductionAddress
						},
					];
					this.testData = [{
							label: '分配人',
							value: res.data.consultationAssignedName
						},
						{
							label: '分配时间',
							value: res.data.deductionAssignedTime
						},
					]
				})
			},
			getSelectallocation(){
				let params = {
					workPlanId: this.work.id,
					consultationDeductionId: this.work.objId
				}
				this.$apiRequest.bzhzyApi.selectallocation(params).then(res => {
					this.distributionData = [{
							label: '会商人员',
							value: res.data.peoplelistName1
						},
						{
							label: '会商时间',
							value: res.data.consultationTime
						},
						{
							label: '会商地点',
							value: res.data.consultationAddress
						},
					];
					this.testData = [{
							label: '分配人',
							value: res.data.consultationAssignedName
						},
						{
							label: '分配时间',
							value: res.data.consultationAssignedTime
						},
					]
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.allocation {
		height: 100vh;
		background: #F2F6FA;
	}
</style>
